const { Sequelize, DataTypes } = require("sequelize");

const sequelize = new Sequelize("exam", "root", "123456", {
    host: "localhost",
    dialect: "mysql",
});

const Student = sequelize.define("student", {
    // 在这里定义模型属性
    uname: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    age: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    sex: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    className: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    salary: {
        type: DataTypes.STRING,
        allowNull: false,
    },
});
const Order = sequelize.define("order", {
    order_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        autoIncrement: true,
    },
    product_name: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    category: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    price: {
        type: DataTypes.DECIMAL,
        allowNull: false,
    },
    order_date: {
        type: DataTypes.DATE,
        allowNull: false,
    },
});

const MovieTicket = sequelize.define("movie_ticket", {
    order_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        autoIncrement: true,
    },
    ticket_type: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    movie_session: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    movie_name: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    ticket_price: {
        type: DataTypes.DECIMAL,
        allowNull: false,
    },
});
const Appointment = sequelize.define("appointment", {
    appointment_id: {
        type: DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        autoIncrement: true,
    },
    patient_name: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    doctor_name: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    department: {
        type: DataTypes.STRING,
        allowNull: false,
    },
    appointment_date: {
        type: DataTypes.DATE,
        allowNull: false,
    },
    fee: {
        type: DataTypes.DECIMAL,
        allowNull: false,
    },
});
module.exports = {
    Student,
    Order,
    MovieTicket,
    Appointment,
};
